﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DEMO3.DTO;
using System.Data.SqlClient;

namespace DEMO3.DAO
{
    class RapChieuDAO
    {
        public DataTable Get()
        {
            DataProvider test = new DataProvider();
            return test.ExcuteQuery("GET_RAPCHIEU", null);
        }

        public bool Add(RapChieuDTO dto)
        {
            DataProvider test = new DataProvider();
            SqlParameter[] arrpara = new SqlParameter[2];
            arrpara[0] = new SqlParameter("TenRap", dto.TenRap);
            arrpara[1] = new SqlParameter("DiaChi", dto.DiaChi);
            return test.ExcuteNonQuery("ADD_RAPCHIEU", arrpara);
        }
        public bool Delete(RapChieuDTO dto)
        {
            DataProvider test = new DataProvider();
            SqlParameter[] arrpara = new SqlParameter[1];
            arrpara[0] = new SqlParameter("MaRap", dto.MaRap);
            return test.ExcuteNonQuery("DELETE_RAPCHIEU", arrpara);
        }
        public bool Update(RapChieuDTO dto)
        {
            DataProvider test = new DataProvider();
            SqlParameter[] arrpara = new SqlParameter[3];
            arrpara[0] = new SqlParameter("MaRap", dto.MaRap);
            arrpara[1] = new SqlParameter("TenRap", dto.TenRap);
            arrpara[2] = new SqlParameter("DiaChi", dto.DiaChi);
            return test.ExcuteNonQuery("UPDATE_RAPCHIEU", arrpara);
        }
    }
}
